package com.christianposta.learnddd.domain.model.voyage;

import org.apache.commons.lang.Validate;


import com.christianposta.learnddd.domain.shared.ValueObject;

public class VoyageNumber implements ValueObject<VoyageNumber> {
	
	private String number;
	
	public VoyageNumber(final String number){
		Validate.notNull(number);
		
		this.number = number;
	}

	public boolean sameValueAs(VoyageNumber other) {
		return other != null && this.number.equals(other.number);
	}
	
	public String idString(){
		return this.number;
	}
	
	@Override
	public String toString() {
		return this.number;
	}
	
	@Override
	public boolean equals(Object o) {
	    if (this == o) return true;
	    if (o == null) return false;
	    if (!(o instanceof VoyageNumber)) return false;

	    final VoyageNumber other = (VoyageNumber) o;
	    
	    return sameValueAs(other);
	}
	
	@Override
	public int hashCode() {
		return this.number.hashCode();
	}

}
